home *** CD-ROM | disk | FTP | other *** search
- #include "all.h"
-
- /*------------------------------------------------------------------*/
- /* Find the function callped *cp, and return it's number */
- /*------------------------------------------------------------------*/
-
- /* You can add a function, you MUST place it in alphabetical order */
- /* and give it the next unused index number */
-
- /* ret = Type of returned value, 1=number, 2=string */
- /* np = number of paramters expected */
- /* Parameters p0...p4 == 1=number, 2=string, 0=none (e.g. height()) . */
-
- #define NKEYS (sizeof keywfn / sizeof(struct keyw))
- struct keyw { char *word; int index; int ret,np,p[5]; } keywfn[] = {
- " ",0 ,1 ,0 ,0,0,0,0,0
- ,"+",1 ,1 ,0 ,0,0,0,0,0
- ,"-",2 ,1 ,0 ,0,0,0,0,0
- ,"ABS",3 ,1 ,1 ,1,0,0,0,0
- ,"ACOS",53 ,1 ,1 ,1,0,0,0,0
- ,"ASIN",54 ,1 ,1 ,1,0,0,0,0
- ,"ATN",4 ,1 ,1 ,1,0,0,0,0
- ,"CHR$",52 ,2 ,1 ,1,0,0,0,0
- ,"COS",5 ,1 ,1 ,1,0,0,0,0
- ,"CVTCOLOR",49 ,1 ,1 ,2,0,0,0,0
- ,"CVTFONT",50 ,1 ,1 ,2,0,0,0,0
- ,"CVTGREY",45 ,1 ,1 ,1,0,0,0,0
- ,"CVTINT",46 ,1 ,1 ,1,0,0,0,0
- ,"CVTMARKER",48 ,1 ,1 ,2,0,0,0,0
- ,"CVTRGB",47 ,1 ,3 ,1,1,1,0,0
- ,"DATE$",6 ,2 ,0 ,0,0,0,0,0
- ,"DEVICE$",51 ,2 ,0 ,0,0,0,0,0
- ,"EOF",55 ,1 ,1 ,1,0,0,0,0
- ,"EXP",7 ,1 ,1 ,1,0,0,0,0
- ,"FEOF",55 ,1 ,1 ,1,0,0,0,0
- ,"FIX",8 ,1 ,1 ,1,0,0,0,0
- ,"HEIGHT",9 ,1 ,1 ,0,0,0,0,0
- ,"INT",10 ,1 ,1 ,1,0,0,0,0
- ,"LEFT$",11 ,2 ,2 ,2,1,0,0,0
- ,"LEN",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YMIN",43 ,1 ,1 ,0,0,0,0,0
- ,"YPOS",44 ,1 ,1 ,0,0,0,0,0
- } ;
-
- int binsearch(char *word, struct keyw tab[], int n);
-
- find_un(char *cp, int *idx,int *ret,int *np,int **plist)
- {
- int i;
- i = binsearch(cp,keywfn,NKEYS);
- *idx = keywfn[i].index;
- *ret = keywfn[i].ret;
- *np = keywfn[i].np;
- *plist = &keywfn[i].p[0];
- }
-
- /*------------------------------------------------------------------*/
- /* Simple binary search */
- /*------------------------------------------------------------------*/
- binsearch(char *word, struct keyw tab[], int n)
- {
- int cond,low,high,mid;
- low = 0;
- high = n-1;
- while (low <= high) {
- mid = (low+high) / 2;
- if ((cond = strcmp(word,tab[mid].word)) < 0)
- high = mid - 1;
- else if (cond > 0)
- low = mid + 1;
- else
- return mid;
- }
- return 0;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-